<include file="nav:header"/>
<div class="container-fluid">
    <div class="row">
        <include file="Left:left-Common"/>
        <div class="col-md-10 right">
            <div class="page-header" style="margin-right: 15px">
                <h3>{$page_title}</h3>
            </div>
            <form class="article_index" action="{:U('Article/batch_del')}" method="post">
                <div class="col-md-12">
                    <div class="index_top">
                        <div style="margin-left: 50px" class="btn-group pull-left " role="group" aria-label="Large button group">
                            <a href="{:U('Article/index')}" type="button" class="btn btn-default">بارلىق ئۇچۇرلار</a>
                            <a href="{:U('Article/add')}"  type="button" class="btn btn-default">ئۇچۇر قوشۇش</a>
                            <button type="button" class="layui-btn pull-left" id="test2" style="margin-right: 10px;margin-top: -2px">
                                <i class="layui-icon"></i>ئامبارغا رەسىم قوشۇش
                            </button>
                            <script type="text/javascript">
                                layui.use('upload', function(){
                                var upload = layui.upload;
                                    var i=0;
                                    upload.render({
                                        elem:'#test2'
                                        ,url:'{:U("Article/uploads")}'
                                        ,multiple:true
                                        ,before:function(obj){obj.preview(function(index,file,result){$('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">')
                                        });}
                                        ,done: function(res){
                                            //上传完毕回调
                                            if(res.status == 1){
                                                i++;
                                                layer.alert(i+"-"+res.message, {
                                                    title:"سېستىما ئەسكەرتىشى",
                                                    btn:"بىلدىم",
                                                    icon: 6,
                                                    skin: 'layer-ext-moon',
                                                    time:500
                                                });
                                                $("#thumb").val(res.src) ;
                                                $("#thumbface").css("display","block") ;
                                                $("#thumbface").attr("src","/"+res.src) ;
                                            }else{
                                                layer.alert(res.message, {
                                                    title:"سېستىما ئەسكەرتىشى",
                                                    btn:"بىلدىم",
                                                    icon: 5,
                                                    skin: 'layer-ext-moon',
                                                    time:1000
                                                });
                                            }
                                        }
                                        ,error: function(){
                                            //请求异常回调
                                        }
                                    })
                                })
                            </script>
                        </div>
                        <div class="col-md-2 pull-left"></div>
                        <input value="{$pa}" onchange="_page(this)" style="width: 5%!important;text-align: center" type="text" class="form-control pull-left">
                        <select onchange="serach(this.value) ;"  class="form-control input-sm serach pull-right" style="width: 20%;font-size: 15px;line-height: 34px;height: 34px">
                            <option <if condition="$get_id eq 0">selected</if>  value="0">بارلىق</option>
                            <foreach name="classify" item="c">
                                <option <if condition="$c.id eq $get_id">selected</if>  value="{$c.id}"><if condition="$c['pid'] neq 0">{$c.lavel|_repeat} ┘─</if>{$c['name']}</option>
                            </foreach>
                        </select>
                        <div class="form-group pull-right col-xs-2">
                            <input type="text"  onKeyDown="return proc_kd(event);" onKeyPress="return addchar(this, event);" class="form-control" id="inputtext" value="{$search}" placeholder="ھالقىلىق سۆز">
                        </div>
                        <a class="btn btn-default pull-right" href="javascript:search_text();" role="button">ئىزدەش</a>
                    </div>
                    <!--所有分类-->
                    <table class="table table-bordered">
                        <thead>
                        <tr class="info">
                            <th width="30"></th>
                            <th width="50">ID</th>
                            <th width="70">مۇقاۋا</th>
                            <th>ئۇچۇر تېمىسى</th>
                            <th style="text-align: center"> تۈرى</th>
                            <th style="text-align: center">ھالىتى</th>
                            <th style="text-align: center">يوللىغۇچى</th>
                            <th style="text-align: center">قوشۇلغان ۋاقتى</th>
                            <th style="text-align: center">ئۆزگەرتكەن ۋاقتى</th>
                            <th style="text-align: center">مەشغۇلات</th>
                        </tr>
                        </thead>
                        <tbody>
                        <foreach name="articles" item="c">
                            <tr class="classifys active">
                                <td><input name="dels[]" value="{$c[id]}" class="del" type="checkbox"></td>
                                <td>{$c['id']}</td>
                                <td><img  width="60px" height="40px" src="/{$c['thumb']|_strpos}" alt=""></td>
                                <td><a href="javasript:;">{$c['title']|_substr}</a></td>
                                <td width="100" style="text-align: center">{$c['name']}</td>
                                <td style="text-align: center">
                                    <if condition="$c['status'] eq 1">
                                        <span style="margin-top: 6px;display: inline-block;"  onclick="_status(this,0,{$c['id']})"  class="btn btn-success btn-xs kaiguan">ئوچۇق</span>
                                        <else/>
                                        <span style="margin-top: 6px;display: inline-block;" onclick="_status(this,1,{$c['id']})" class="btn btn-danger btn-xs kaiguan">تاقاق</span>
                                    </if>
                                </td>
                                <td>{$c['author']}</td>
                                <td style="direction: ltr;text-align: center">{$c['intime']|date='Y-m-d H:i:s',###}</td>
                                <td style="direction: ltr;text-align: center">{$c['uptime']|date='Y-m-d H:i:s',###}</td>
                                <td style="text-align: center">
                                    <a  style="margin-top: 6px;display: inline-block;" href="{:U('Article/edit',array('id'=>$c['id']))}" class="btn btn-success btn-xs ">تەھرىرلەش</a>
                                    <a  style="margin-top: 6px;display: inline-block;" href="javascript:del({$c['id']});" class="btn btn-danger btn-xs">ئۆچۈرۈش</a>
                                </td>
                            </tr>
                        </foreach>
                        </tbody>
                    </table>
                    <div style="margin-top: -10px" class="page_ye">
                        <dl>
                            <dd>جەمئى {$count} تال ئۇچۇر بار</dd>
                        </dl>
                        <!--分页-->
                        {$page}
                        <ul class="quan_xuan">
                            <li><input  onclick="CheckedAll()" class="layui-btn layui-btn-mini quan_xuan_btn1" type="button" value="ھەممىنى تاللاش"></li>
                            <li><input class="layui-btn layui-btn-danger layui-btn-mini quan_xuan_btn2" type="submit" value="  تاللىغاننى ئۆچۈرۈش"></li>
                        </ul>
                        <div style="clear:both;height: 2px;"></div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    //Demo
    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function(data){
            layer.msg(JSON.stringify(data.field));
            return false;
        });
    });
    function search_text() {
        var value=$("#inputtext").val();
        if(value==""){
            window.location.href="{:U('Article/index')}";
        }else {
            window.location.href="{:U('Article/index')}?search="+encodeURIComponent(value);
        }
    }
    function serach(val) {
        window.location.href="{:U('Article/index')}?id="+val;
    }
    //删除分类
    function del(id) {
        layer.confirm('بۇ ئۇچۇرنى راستىنلا ئۆچۈرەمسىز ؟', {
            btn: ['ھەئە','ياق'] ,//按钮,
            title:"سېستىما ئەسكەرتىشى"
        }, function(){
            $.ajax({
                type:"post",
                url:"{:U('Article/del')}",
                dataType:"json",
                data:{"id":id},
                success:function (phpdata) {
                    if(phpdata.status==1){
                        layer.alert(phpdata.message, {
                            title:"سېستىما ئەسكەرتىشى",
                            btn:"بىلدىم",
                            icon: 6,
                            skin: 'layer-ext-moon',
                            time:800
                        });
                        window.location=location;
                    }else{
                        layer.alert(phpdata.message, {
                            title:"سېستىما ئەسكەرتىشى",
                            btn:"بىلدىم",
                            icon: 5,
                            skin: 'layer-ext-moon',
                            time:1000
                        });
                    }
                }
            })
        });

    }
    //分类状态
    function _status(obj,status,id) {
        if(status=='0'){
            $(obj).removeClass("btn-success");
            $(obj).addClass("btn-danger");
            $(obj).text("تاقاق")
        }else {
            $(obj).removeClass("btn-danger");
            $(obj).addClass("btn-success");
            $(obj).text("ئوچۇق")
        }
        $.ajax({
            type:"post",
            url:"{:U('Article/sortStatus')}",
            dataType:"json",
            data:{"id":id,"status":status},
            success:function (phpdata) {
                if(phpdata.status==1){
                    layer.alert(phpdata.content, {
                        title:"سېستىما ئەسكەرتىشى",
                        btn:"بىلدىم",
                        icon: 6,
                        skin: 'layer-ext-moon',
                        time:400
                    });
                    window.location=location;
                }else{
                    layer.alert(phpdata.content, {
                        title:"سېستىما ئەسكەرتىشى",
                        btn:"بىلدىم",
                        icon: 5,
                        skin: 'layer-ext-moon',
                        time:1000
                    });
                }
            }
        })
    }
    function _page(obj) {
       var val=obj.value;
       $.ajax({
           type:"post",
           url:"{:U('Article/page')}",
           dataType:"json",
           data:{"page":val},
           success:function (phpdata) {
               if(phpdata.status==1){
                   layer.alert(phpdata.content, {
                       title:"سېستىما ئەسكەرتىشى",
                       btn:"بىلدىم",
                       icon: 6,
                       skin: 'layer-ext-moon',
                       time:2500
                   });
                   window.location=location;
               }else{
                   layer.alert(phpdata.content, {
                       title:"سېستىما ئەسكەرتىشى",
                       btn:"بىلدىم",
                       icon: 5,
                       skin: 'layer-ext-moon',
                       time:1000
                   });
               }
           }
       })

    }
    $(function () {
        $('.classifys').hover(function () {
            $(this).addClass('info');
        },function () {
            $(".classifys").removeClass('info');
        })
    })
</script>
<include file="nav:footer"/>